package cn.neusoft.luofa603.yuejian_29.fragment;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.HashMap;
import java.util.List;
import cn.neusoft.luofa603.yuejian_29.R;
import cn.neusoft.luofa603.yuejian_29.adapter.ClubVideoAdapter;
import cn.neusoft.luofa603.yuejian_29.bean.Video;
import cn.neusoft.luofa603.yuejian_29.model.VideoModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ClubVideoFragment extends Fragment {
    private RecyclerView recyclerView;
    private View view;
    private VideoModel videoModel;



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.fragment_clubvideo, container, false);

        initViews();
        initEvents();
        initData();
        return view;
    }
    public void initViews(){

        recyclerView = (RecyclerView) view.findViewById(R.id.video_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        VideoModel videoModel = new VideoModel();
        Call<List<Video>> call = videoModel.getVideoList();
        call.enqueue(new Callback<List<Video>>() {

            public void onResponse(Call<List<Video>> call, Response<List<Video>> response) {
                final List<Video> mDataList = response.body();
                ClubVideoAdapter clubVideoAdapter = new ClubVideoAdapter(getActivity(),mDataList);
                recyclerView.setAdapter(clubVideoAdapter);
            }

            public void onFailure(Call<List<Video>> call, Throwable t) {

                t.printStackTrace();
            }

        });
    }
    public void initEvents(){

    }

    public void initData(){

    }

}
